classdef Xmiss_dev < Processor_dev
  % Class for calculating transmissivity ala SBE Data Procesing
  % Derived from Processor_dev
  % Constructor signature: Xmiss = Xmiss_dev(data, conn), both args. optional
  %
  % Author: David Goldsmith, Wash. State Dept. of Ecology, dgol461@ecy.wa.gov
  % Release date: N/A
  
    properties
      % inherited from Processor_dev
%         inData;
%         castDT;
%         scanRate;
%         ParamID;
%         ParamDesc;
%         SBEprec;
%         EquipID;
        DBdata;
        outData = struct('Xmiss', [], 'Beam_c', []);
    end
    
    methods
        function Xmiss = Xmiss_dev(data, conn) % Constructor
            if nargin < 1
                data = [];
            end
            if nargin < 2
                conn = [];
            end
            Xmiss = Xmiss@Processor_dev(data);
            if ~isempty(conn)
                Xmiss.getDBdata(conn, 'X');
            end
            if ~isempty(conn) && ~isempty(data)
                Xmiss.mainFormula();
            end
        end
        
        function delete(obj) % Destructor
            % Here in case I need it
        end
        
        function mainFormula(obj)
            M = obj.inData.Sensors.TransChelseaSeatechWetlabCStarSensor.M;
            B = obj.inData.Sensors.TransChelseaSeatechWetlabCStarSensor.B;
            PL = obj.inData.Sensors.TransChelseaSeatechWetlabCStarSensor. ...
                 PathLength;
            tmp = B + M * obj.inData.rV(:,obj.inData.Sensors. ...
                              TransChelseaSeatechWetlabCStarSensor.index-2);
            tmp(tmp<0 | tmp>100) = NaN;
            obj.outData.Xmiss = tmp;
            obj.outData.Beam_c = -log(tmp/100)/PL;
        end
        
    end
    
end